package com.jqr.activity.myroomcart;

import android.app.Application;
import android.content.res.Configuration;

import androidx.annotation.NonNull;
import androidx.room.Room;

import com.jqr.activity.myroomcart.database.BookDatabase;

public class MyApplication extends Application {

    private  static  MyApplication mApp;

    private BookDatabase bookDatabase;
    public static MyApplication getInstance(){
        return mApp;
    }


    @Override
    public void onCreate() {
        super.onCreate();
        mApp=this;
        bookDatabase= Room.databaseBuilder(this, BookDatabase.class,"book.db")
                .addMigrations() //防止数据更新时，老得数据被删除
                .allowMainThreadQueries() //容许在主线程进行操作，实际要删除
                .build();
    }

    @Override
    public void onTerminate() {
        super.onTerminate();
    }

    @Override
    public void onConfigurationChanged(@NonNull Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
    }

    public BookDatabase getBookDB(){
        return bookDatabase;
    }


}
